﻿using dotHTML;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace TestdotHTML
{
    
    
    /// <summary>
    ///This is a test class for ElementTest and is intended
    ///to contain all ElementTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ElementTest {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext {
            get {
                return testContextInstance;
            }
            set {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        internal virtual Element CreateElement() {
            /* We use <b> to wrap Element, as it is a concrete
             * derived class of Element with no extra code. */
            return new dotHTML.HTML.B();
        }

        /// <summary>
        ///A test for ToString
        ///</summary>
        [TestMethod()]
        public void ToStringTest() {
            Element e = CreateElement();
            e.AccessKey.Add('a');
            e.AccessKey.Add('b');
            dotHTML.HTML.I i = new dotHTML.HTML.I();
            dotHTML.HTML.U u = new dotHTML.HTML.U();
            e.Children.Add(i);
            e.Children.Add(u);
            e.Class.Add("ac1");
            e.Class.Add("ac2");
            e.ContentEditable = true;
            e.DataSet.Add("one", "strone");
            e.DataSet.Add("two", "strtwo");
            e.Dir = Element.TextDirection.LTR;
            e.Draggable = true;
            e.DropZone = Element.DropZoneAction.Copy;
            e.Events.Add("three", "strthree");
            e.Events.Add("four", "strfour");
            e.Hidden = true;
            e.ID = "id";
            e.Lang = "lang";
            e.Spellcheck = true;
            e.Style="style";
            e.TabIndex = 1;
            e.Title = "title";
            Assert.AreEqual("<b accesskey=\"a b \" " +
                "class=\"ac1 ac2 \" " +
                "contenteditable=\"true\" " +
                "data-one=\"strone\" " +
                "data-two=\"strtwo\" " +
                "dir=\"ltr\" " +
                "draggable=\"true\" " +
                "dropzone=\"copy\" " +
                "three=\"strthree\" " +
                "four=\"strfour\" " +
                "hidden=\"hidden\" " +
                "id=\"id\" " +
                "lang=\"lang\" " +
                "spellcheck=\"true\" " +
                "style=\"style\" " +
                "tabindex=\"1\" " +
                "title=\"title\"><i></i><u></u></b>", e.ToString());
        }

        /// <summary>
        ///A test for AccessKeys
        ///</summary>
        [TestMethod()]
        public void AccessKeysTest() {
            Element target = CreateElement();
            target.AccessKey.Add('a');
            target.AccessKey.Add('b');
            Assert.IsTrue(target.AccessKey.Count == 2);
            Assert.IsTrue(target.AccessKey.Contains('a'));
            Assert.IsTrue(target.AccessKey.Contains('b'));
        }

        /// <summary>
        ///A test for Children
        ///</summary>
        [TestMethod()]
        public void ChildrenTest() {
            Element target = CreateElement();
            dotHTML.HTML.I i = new dotHTML.HTML.I();
            dotHTML.HTML.U u = new dotHTML.HTML.U();
            target.Children.Add(i);
            target.Children.Add(u);
            Assert.IsTrue(target.Children.Count == 2);
            Assert.IsTrue(target.Children.Contains(i));
            Assert.IsTrue(target.Children.Contains(u));
        }

        /// <summary>
        ///A test for Class
        ///</summary>
        [TestMethod()]
        public void ClassTest() {
            Element target = CreateElement();
            target.Class.Add("ac1");
            target.Class.Add("ac2");
            Assert.IsTrue(target.Class.Count == 2);
            Assert.IsTrue(target.Class.Contains("ac1"));
            Assert.IsTrue(target.Class.Contains("ac2"));
        }

        /// <summary>
        ///A test for ContentEditable
        ///</summary>
        [TestMethod()]
        public void ContentEditableTest() {
            Element target = CreateElement();
            Nullable<bool> expected = false;
            Nullable<bool> actual;
            target.ContentEditable = expected;
            actual = target.ContentEditable;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for DataSet
        ///</summary>
        [TestMethod()]
        public void DataSetTest() {
            Element target = CreateElement();
            target.DataSet.Add("one", "strone");
            target.DataSet.Add("two", "strtwo");
            Assert.IsTrue(target.DataSet.Count == 2);
            Assert.IsTrue(target.DataSet.ContainsKey("one"));
            Assert.IsTrue(target.DataSet.ContainsKey("two"));
        }

        /// <summary>
        ///A test for Dir
        ///</summary>
        [TestMethod()]
        public void DirTest() {
            Element target = CreateElement();
            Nullable<Element.TextDirection> expected = Element.TextDirection.LTR;
            Nullable<Element.TextDirection> actual;
            target.Dir = expected;
            actual = target.Dir;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Draggable
        ///</summary>
        [TestMethod()]
        public void DraggableTest() {
            Element target = CreateElement();
            Nullable<bool> expected = true;
            Nullable<bool> actual;
            target.Draggable = expected;
            actual = target.Draggable;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for DropZone
        ///</summary>
        [TestMethod()]
        public void DropZoneTest() {
            Element target = CreateElement();
            Nullable<Element.DropZoneAction> expected = Element.DropZoneAction.Copy;
            Nullable<Element.DropZoneAction> actual;
            target.DropZone = expected;
            actual = target.DropZone;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Events
        ///</summary>
        [TestMethod()]
        public void EventsTest() {
            Element target = CreateElement();
            target.Events.Add("one", "strone");
            target.Events.Add("two", "strtwo");
            Assert.IsTrue(target.Events.Count == 2);
            Assert.IsTrue(target.Events.ContainsKey("one"));
            Assert.IsTrue(target.Events.ContainsKey("two"));
        }

        /// <summary>
        ///A test for Hidden
        ///</summary>
        [TestMethod()]
        public void HiddenTest() {
            Element target = CreateElement();
            bool expected = false;
            bool actual;
            target.Hidden = expected;
            actual = target.Hidden;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ID
        ///</summary>
        [TestMethod()]
        public void IDTest() {
            Element target = CreateElement();
            string expected = string.Empty;
            string actual;
            target.ID = expected;
            actual = target.ID;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Lang
        ///</summary>
        [TestMethod()]
        public void LangTest() {
            Element target = CreateElement();
            string expected = string.Empty;
            string actual;
            target.Lang = expected;
            actual = target.Lang;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Spellcheck
        ///</summary>
        [TestMethod()]
        public void SpellcheckTest() {
            Element target = CreateElement();
            Nullable<bool> expected = false;
            Nullable<bool> actual;
            target.Spellcheck = expected;
            actual = target.Spellcheck;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Style
        ///</summary>
        [TestMethod()]
        public void StyleTest() {
            Element target = CreateElement();
            string expected = string.Empty;
            string actual;
            target.Style = expected;
            actual = target.Style;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for TabIndex
        ///</summary>
        [TestMethod()]
        public void TabIndexTest() {
            Element target = CreateElement();
            Nullable<int> expected = 1;
            Nullable<int> actual;
            target.TabIndex = expected;
            actual = target.TabIndex;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Title
        ///</summary>
        [TestMethod()]
        public void TitleTest() {
            Element target = CreateElement();
            string expected = string.Empty;
            string actual;
            target.Title = expected;
            actual = target.Title;
            Assert.AreEqual(expected, actual);
        }
    }
}
